package qita.somme5chiffres.sol1;

import java.util.HashSet;
import java.util.Set;

public class Solution1 {
	public static void main(String[] args) {
		Set<Set<Integer>> resultSet = new HashSet<Set<Integer>>();

//		Date date1 = new Date();
		for (int a = 1; a <= 500; ++a) {
			for (int b = 1; b <= 500; ++b) {
				if (a == b) {
					continue;
				}
				// a != b
				for (int c = 1; c <= 500; ++c) {
					if (c == a || c == b) {
						continue;
					}
					// c != a && c != b (&& a != b)
					for (int d = 1; d <= 500; ++d) {
						if (d == a || d == b || d == c) {
							continue;
						}
						// d != a && d != b && d != c (&& c != a && c != b && a != b)
						for (int e = 1; e <= 500; ++e) {
							if (e == a || e == b || e == c || e == d) {
								continue;
							}
							if ((a + b + c + d + e) % 5 == 0) {
								HashSet<Integer> result = new HashSet<Integer>();
								result.add(a);
								result.add(b);
								result.add(c);
								result.add(d);
								result.add(e);
								if (resultSet.add(result)) {
									System.out.println("加入" + result);
								}
								else {
									System.out.println(result + " 结果已存在！");
								}
							}
						}
					}
				}
			}
		}
//		Date date2 = new Date();

		System.out.println("结果一共有" + resultSet.size() + "个\n分别是：" + resultSet);
	}
}
